package cn.wolfcode.producer._02_send_type;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
//演示一次性发送的发送消息方式
public class Producer3 {
    public static void main(String[] args) throws Exception {
        //1.创建生产者对象
        DefaultMQProducer defaultMQProducer = new DefaultMQProducer("producer-demo");
        //2.设置名字服务器地址
        defaultMQProducer.setNamesrvAddr("127.0.0.1:9876");
        //3.启动生产者
        defaultMQProducer.start();
        //4.创建消息并发送消息
        Message message = new Message("02-send-type","你好RocketMQ".getBytes());
        defaultMQProducer.sendOneway(message);
//        System.out.println(sendResult.getSendStatus());
//        System.out.println(sendResult.getMsgId());
        //5.关闭资源
        defaultMQProducer.shutdown();
    }
}
